﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using dto;
using util;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Data;
using common;
using dto;
using System.Reflection;
using System.Windows.Forms;

namespace dao
{
    public class MenuDAO
    {
        /* Author : James
         * Date : 17/4/2012
         * function get the values menu in database
         * add the values in DataTable
         * return DataTable
         */
        
        public DataTable getListMenu()
        {
            DataTable dttListMenu = new DataTable();
            try
            {
                DataUtil.connect();
                dttListMenu = DataUtil.executeStore("sp_getMenuValues", null);
            }
            catch (Exception e)
            {
                throw;
            }
            return dttListMenu;
        }
        public UserControl FunctionShowUserControl(Type typeFunction)
        {
            object oUserControl = new object();
            Type tUserControl = typeFunction;

            if (tUserControl != null)
            {
                oUserControl = Activator.CreateInstance(tUserControl);
                //((Form)oForm).ShowDialog();$
                //splitContainer1.Panel2.Controls.Add((Form)oForm);
                //((Form)oForm).Dock = DockStyle.Fill;
            }
            else
            {
                oUserControl = new UserControl();
            }
            return ((UserControl)oUserControl );
        }
        public Form FunctionShowForm(Type typeFunction)
        {
            object oForm = new object();
            Type tForm = typeFunction;
            if (tForm != null)
            {
                oForm = Activator.CreateInstance(tForm);
                //((Form)oForm).ShowDialog();
                //splitContainer1.Panel2.Controls.Add((Form)oForm);
                //((Form)oForm).Dock = DockStyle.Fill;
            }
            else
            {
                oForm = new Form();
            }
            return ((Form)oForm);
        }
    }
}
